<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../templates/StakeholderPortalTemplate.xhtml">

    <ui:define name="content">
        <f:view beforePhase="#{stakeholderULPManagerBean.initULPItemApplicationList}"></f:view>
        <h:form id="formMain">
            <h1>Track All ULP Item Applications</h1>         

            <p:panel header="Track ULP Item Applications">
                <p:accordionPanel autoHeight="false">
                    <p:tab title="Pending Applications">
                        <p:dataTable var="pendingApplication" value="#{stakeholderULPManagerBean.pendingULPItemApplicationList}" paginator="true" 
                                     rows="10" emptyMessage="No pending application" selection="#{stakeholderULPManagerBean.selectedULPItemApplication}" 
                                     selectionMode="single" rowSelectListener="#{stakeholderULPManagerBean.onRowSelectNavigateULPItemApplication}"
                                     dblClickSelect="true">

                            <p:column sortBy="#{pendingApplication.id}" filterBy="#{pendingApplication.id}">
                                <f:facet name="header">
                                    <h:outputText value="ID" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.id}" />
                            </p:column>

                            <p:column sortBy="#{pendingApplication.name}" filterBy="#{pendingApplication.name}">
                                <f:facet name="header">
                                    <h:outputText value="Name" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.name}" />
                            </p:column>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Image" />
                                </f:facet>
                                <p:graphicImage id="imageDisplay" value="/images/upload/media/#{pendingApplication.imageURL}"
                                                height="50" width="70"/> 
                            </p:column>

                            <p:column sortBy="#{pendingApplication.costOfItem}" filterBy="#{pendingApplication.costOfItem}">
                                <f:facet name="header">
                                    <h:outputText value="Offered Price" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.costOfItem} SGD" />
                            </p:column>

                            <p:column sortBy="#{pendingApplication.maxQuantity}" filterBy="#{pendingApplication.maxQuantity}">
                                <f:facet name="header">
                                    <h:outputText value="Maximum Quantity" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.maxQuantity}" />
                            </p:column>

                            <p:column sortBy="#{pendingApplication.validFrom}" filterBy="#{pendingApplication.validFrom}">
                                <f:facet name="header">
                                    <h:outputText value="Offer From" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.validFrom}">
                                    <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                                </h:outputText>
                            </p:column>

                            <p:column sortBy="#{pendingApplication.validUntil}" filterBy="#{pendingApplication.validUntil}">
                                <f:facet name="header">
                                    <h:outputText value="Offer Until" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.validUntil}">
                                    <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                                </h:outputText>
                            </p:column>

                            <p:column sortBy="#{pendingApplication.status}" filterBy="#{pendingApplication.status}">
                                <f:facet name="header">
                                    <h:outputText value="Status" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.status}" />
                            </p:column>

                        </p:dataTable>
                    </p:tab>
                    <p:tab title="All ULPItem applications">
                        <p:dataTable var="ULPItemApplication" value="#{stakeholderULPManagerBean.ULPItemApplicationList}" paginator="true" 
                                     rows="10" emptyMessage="No application" selection="#{stakeholderULPManagerBean.selectedULPItemApplication}" 
                                     selectionMode="single" rowSelectListener="#{stakeholderULPManagerBean.onRowSelectNavigateULPItemApplication}"
                                     dblClickSelect="true">

                            <p:column sortBy="#{ULPItemApplication.id}" filterBy="#{ULPItemApplication.id}">
                                <f:facet name="header">
                                    <h:outputText value="ID" />
                                </f:facet>
                                <h:outputText value="#{ULPItemApplication.id}" />
                            </p:column>

                            <p:column sortBy="#{ULPItemApplication.name}" filterBy="#{ULPItemApplication.name}">
                                <f:facet name="header">
                                    <h:outputText value="Name" />
                                </f:facet>
                                <h:outputText value="#{ULPItemApplication.name}" />
                            </p:column>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Image" />
                                </f:facet>
                                <p:graphicImage id="imageDisplay" value="/images/upload/media/#{ULPItemApplication.imageURL}"
                                                height="50" width="70"/> 
                            </p:column>

                            <p:column sortBy="#{ULPItemApplication.costOfItem}" filterBy="#{ULPItemApplication.costOfItem}">
                                <f:facet name="header">
                                    <h:outputText value="Cost of item" />
                                </f:facet>
                                <h:outputText value="#{ULPItemApplication.costOfItem} SGD" />
                            </p:column>

                            <p:column sortBy="#{ULPItemApplication.maxQuantity}" filterBy="#{ULPItemApplication.maxQuantity}">
                                <f:facet name="header">
                                    <h:outputText value="Minimum Quantity" />
                                </f:facet>
                                <h:outputText value="#{ULPItemApplication.maxQuantity}" />
                            </p:column>

                            <p:column sortBy="#{ULPItemApplication.validFrom}" filterBy="#{ULPItemApplication.validFrom}">
                                <f:facet name="header">
                                    <h:outputText value="Offer From" />
                                </f:facet>
                                <h:outputText value="#{ULPItemApplication.validFrom}">
                                    <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                                </h:outputText>
                            </p:column>

                            <p:column sortBy="#{ULPItemApplication.validUntil}" filterBy="#{ULPItemApplication.validUntil}">
                                <f:facet name="header">
                                    <h:outputText value="Offer Until" />
                                </f:facet>
                                <h:outputText value="#{ULPItemApplication.validUntil}">
                                    <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                                </h:outputText>
                            </p:column>

                            <p:column sortBy="#{ULPItemApplication.status}" filterBy="#{ULPItemApplication.status}">
                                <f:facet name="header">
                                    <h:outputText value="Status" />
                                </f:facet>
                                <h:outputText value="#{ULPItemApplication.status}" />
                            </p:column>
                        </p:dataTable>
                    </p:tab> 
                </p:accordionPanel> 
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>